
/*
 * FormPemasukan.java
 *
 * Created on 03 Nov 12, 12:26:54
 */
package Pemasukan;

import Pengeluaran.Pengeluaran;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import siabukukaskoperasi.FormUtama;
import tools.koneksi;

//keterangan form ini
//atas nama akan otomatis muncul, ketika id anggota di klik enter
//keterangan yaitu bisa disesuaikan(bila simpanan maka beri keterangan simpanan, bila
//cicilan maka beri keterangan bahwa itu cicilan
/**
 *
 * @author w7
 */
public class FormPemasukan extends javax.swing.JFrame {

    /**
     * Creates new form FormPemasukan
     */
    public FormPemasukan() {

        initComponents();
        GregorianCalendar gc = new GregorianCalendar();
        tTanggal.setDate(gc.getTime());
        tIDAnggota.requestFocus();
        //      tLamaPinjam.setText("12");
        // no_invoice();

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        BtnSimpan1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        labelTgl = new javax.swing.JLabel();
        labelSmberDna = new javax.swing.JLabel();
        tNamaAnggota = new javax.swing.JTextField();
        labelJmlDnaMsk = new javax.swing.JLabel();
        TFJmlDnaMsk = new javax.swing.JTextField();
        labelKdRekening = new javax.swing.JLabel();
        ComboKdRekening = new javax.swing.JComboBox();
        labelAngsuran = new javax.swing.JLabel();
        TFangsuran = new javax.swing.JTextField();
        TFBunga = new javax.swing.JTextField();
        labelBunga = new javax.swing.JLabel();
        labelSmberDna1 = new javax.swing.JLabel();
        tInvoice = new javax.swing.JTextField();
        labelTgl1 = new javax.swing.JLabel();
        tIDAnggota = new javax.swing.JTextField();
        pemasukkan = new javax.swing.JLabel();
        labelBunga1 = new javax.swing.JLabel();
        tKeterangan = new javax.swing.JTextField();
        labelBunga2 = new javax.swing.JLabel();
        tCicilanKe = new javax.swing.JTextField();
        labelBunga3 = new javax.swing.JLabel();
        tLamaPinjam = new javax.swing.JTextField();
        tTanggal = new com.toedter.calendar.JDateChooser();
        labelBunga4 = new javax.swing.JLabel();
        labelPokokPinjaman = new javax.swing.JLabel();
        TFpokokPinjaman = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        bKeluar = new javax.swing.JButton();
        bBatal = new javax.swing.JButton();
        BtnSimpan = new javax.swing.JButton();

        jButton1.setText("jButton1");

        BtnSimpan1.setText("Simpan");
        BtnSimpan1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnSimpan1ActionPerformed(evt);
            }
        });

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel4.setBackground(new java.awt.Color(102, 0, 204));

        jLabel6.setFont(new java.awt.Font("Imprint MT Shadow", 0, 36));
        jLabel6.setText("KOPERASI KREDIT KARYA JASA");

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/Logo-Koperasi.gif"))); // NOI18N
        jLabel7.setText("jLabel1");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel6)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        labelTgl.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelTgl.setText("Tanggal  : ");

        labelSmberDna.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelSmberDna.setText("Nama Anggota                          :");

        tNamaAnggota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tNamaAnggotaActionPerformed(evt);
            }
        });

        labelJmlDnaMsk.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelJmlDnaMsk.setText("Jumlah Dana Masuk                  :");

        TFJmlDnaMsk.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                TFJmlDnaMskMousePressed(evt);
            }
        });
        TFJmlDnaMsk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TFJmlDnaMskActionPerformed(evt);
            }
        });
        TFJmlDnaMsk.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                TFJmlDnaMskKeyReleased(evt);
            }
        });

        labelKdRekening.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelKdRekening.setText(" Kode Rekening                         :");

        ComboKdRekening.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "P1", "P2", "P3", "P4", "P5" }));
        ComboKdRekening.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComboKdRekeningActionPerformed(evt);
            }
        });
        ComboKdRekening.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
                ComboKdRekeningCaretPositionChanged(evt);
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
            }
        });

        labelAngsuran.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelAngsuran.setText("Angsuran                                  :");

        TFangsuran.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TFangsuranActionPerformed(evt);
            }
        });
        TFangsuran.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                TFangsuranKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                TFangsuranKeyReleased(evt);
            }
        });

        TFBunga.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TFBungaActionPerformed(evt);
            }
        });

        labelBunga.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelBunga.setText("Bunga                                       :");

        labelSmberDna1.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelSmberDna1.setText("ID Anggota                               :");

        tInvoice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tInvoiceActionPerformed(evt);
            }
        });
        tInvoice.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tInvoiceKeyPressed(evt);
            }
        });

        labelTgl1.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelTgl1.setText("No. Invoice           :");

        tIDAnggota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tIDAnggotaActionPerformed(evt);
            }
        });
        tIDAnggota.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tIDAnggotaKeyPressed(evt);
            }
        });

        pemasukkan.setFont(new java.awt.Font("Goudy Stout", 0, 18)); // NOI18N
        pemasukkan.setText("bukti penerimaan");

        labelBunga1.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelBunga1.setText("Cicilan Ke-                                 :");

        tKeterangan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tKeteranganActionPerformed(evt);
            }
        });

        labelBunga2.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelBunga2.setText("Keterangan                               :");

        tCicilanKe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tCicilanKeActionPerformed(evt);
            }
        });

        labelBunga3.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelBunga3.setText("Lama pinjam                             :");

        tLamaPinjam.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tLamaPinjamActionPerformed(evt);
            }
        });
        tLamaPinjam.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tLamaPinjamKeyPressed(evt);
            }
        });

        labelBunga4.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelBunga4.setText("bulan");

        labelPokokPinjaman.setFont(new java.awt.Font("Tahoma", 0, 14));
        labelPokokPinjaman.setText("Pokok Pinjaman                        :");

        TFpokokPinjaman.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TFpokokPinjamanActionPerformed(evt);
            }
        });
        TFpokokPinjaman.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                TFpokokPinjamanKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                TFpokokPinjamanKeyReleased(evt);
            }
        });

        bKeluar.setFont(new java.awt.Font("Tahoma", 1, 14));
        bKeluar.setText("Keluar");
        bKeluar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bKeluarActionPerformed(evt);
            }
        });

        bBatal.setFont(new java.awt.Font("Tahoma", 1, 14));
        bBatal.setText("Batal");
        bBatal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bBatalActionPerformed(evt);
            }
        });

        BtnSimpan.setFont(new java.awt.Font("Tahoma", 1, 14));
        BtnSimpan.setText("Simpan");
        BtnSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnSimpanActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGap(83, 83, 83)
                .addComponent(BtnSimpan, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(bBatal, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(bKeluar, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(81, 81, 81))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bBatal, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnSimpan, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bKeluar, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pemasukkan, javax.swing.GroupLayout.PREFERRED_SIZE, 355, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelBunga)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(labelJmlDnaMsk)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(labelTgl1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tInvoice, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(labelKdRekening)
                                    .addComponent(labelSmberDna1)
                                    .addComponent(labelBunga2)
                                    .addComponent(labelSmberDna, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(labelBunga1)
                                    .addComponent(labelAngsuran)
                                    .addComponent(labelBunga3, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE))
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addGap(206, 206, 206)
                                        .addComponent(labelTgl)
                                        .addGap(22, 22, 22))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(34, 34, 34)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(TFJmlDnaMsk, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(tKeterangan, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(tNamaAnggota, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(TFpokokPinjaman, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(TFBunga, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(tLamaPinjam, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                    .addComponent(labelBunga4, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(40, 40, 40))
                                                .addComponent(tCicilanKe, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(TFangsuran, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(36, 36, 36)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(ComboKdRekening, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(tIDAnggota, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addComponent(tTanggal, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(labelPokokPinjaman)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(90, 90, 90)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(75, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(pemasukkan, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelTgl1)
                            .addComponent(tInvoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tTanggal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelTgl))))
                .addGap(48, 48, 48)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ComboKdRekening, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelKdRekening))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelSmberDna1)
                    .addComponent(tIDAnggota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tNamaAnggota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelSmberDna))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelBunga2)
                    .addComponent(tKeterangan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelJmlDnaMsk)
                    .addComponent(TFJmlDnaMsk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(labelPokokPinjaman))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TFpokokPinjaman, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
<<<<<<< .mine
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelAngsuran)
                    .addComponent(TFangsuran, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelBunga3)
=======
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelBunga1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tCicilanKe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(labelAngsuran))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(TFangsuran, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(labelBunga4)
                        .addGap(3, 3, 3))
>>>>>>> .r95
                    .addComponent(tLamaPinjam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelBunga4))
                .addGap(14, 14, 14)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelBunga)
                    .addComponent(TFBunga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tCicilanKe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelBunga1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 787, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 762, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tNamaAnggotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tNamaAnggotaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tNamaAnggotaActionPerformed

    private void TFBungaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TFBungaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TFBungaActionPerformed

    private void TFJmlDnaMskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TFJmlDnaMskActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TFJmlDnaMskActionPerformed

    private void BtnSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnSimpanActionPerformed
        // TODO add your handling code here:

        if (BtnSimpan.getText().equals("Simpan")) {

            String x = ComboKdRekening.getSelectedItem().toString();
            if (x.equalsIgnoreCase("P1") || x.equalsIgnoreCase("P2") || x.equalsIgnoreCase("P3") || x.equalsIgnoreCase("P4")) {
                SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
                Date tanggal = tTanggal.getDate();
                String noInvoice = tInvoice.getText();
                String kodeRek = ComboKdRekening.getSelectedItem().toString();
                String idAnggota = tIDAnggota.getText();
                String atasNama = tNamaAnggota.getText();
                String keterangan = tKeterangan.getText();
                double jmlhDanaMsuk = Double.parseDouble(TFJmlDnaMsk.getText());

                System.out.println(" " + tInvoice.getText());
                System.out.println(" " + tIDAnggota.getText());
                System.out.println(" " + tNamaAnggota.getText());
                System.out.println(" " + tKeterangan.getText());
                System.out.println(" " + TFJmlDnaMsk.getText());

                Pemasukan k = new Pemasukan();
                k.setTanggal(tanggal);
                k.setNoInvoice(noInvoice);
                k.setID_Anggota(idAnggota);
                k.setKodeRekening(kodeRek);
                k.setKeterangan(keterangan);
                k.setNama_anggota(atasNama);
                k.setJumlahDanaMasuk(jmlhDanaMsuk);
                try {
                    PemasukanKontrol.getKoneksiPemasukan().tambahDataSimpanan(k);
                    JOptionPane.showMessageDialog(this, "Pemasukkan dari " + k.getNama_anggota() + " berhasil disimpan!");
                    kosong();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(this, "Pemasukkan gagal disimpan" + " \n error: " + ex.getMessage());
                }
            } else if (x.equalsIgnoreCase("P5")) {
                SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
                Date tanggal = tTanggal.getDate();
                String noInvoice = tInvoice.getText();
                String kodeRek = ComboKdRekening.getSelectedItem().toString();
                String idAnggota = tIDAnggota.getText();
                String atasNama = tNamaAnggota.getText();
                String keterangan = tKeterangan.getText();
                double jmlhDanaMsuk = Double.parseDouble(TFJmlDnaMsk.getText());
                double angsuran = Double.parseDouble(TFangsuran.getText());
                double bunga = Double.parseDouble(TFBunga.getText());
                String cicilanKe = tCicilanKe.getText();
                double pokokpinjaman = Double.parseDouble(TFpokokPinjaman.getText());
                Double lamaPinjam = Double.parseDouble(tLamaPinjam.getText());

                System.out.println(" " + tInvoice.getText());
                System.out.println(" " + tIDAnggota.getText());
                System.out.println(" " + tNamaAnggota.getText());
                System.out.println(" " + tKeterangan.getText());
                System.out.println(" " + TFJmlDnaMsk.getText());
                System.out.println(" " + TFangsuran.getText());
                System.out.println(" " + TFBunga.getText());
                System.out.println(" " + tCicilanKe.getText());
                System.out.println(" " + tLamaPinjam.getText());

                Pemasukan k = new Pemasukan();
                k.setTanggal(tanggal);
                k.setNoInvoice(noInvoice);
                k.setID_Anggota(idAnggota);
                k.setKodeRekening(kodeRek);
                k.setKeterangan(keterangan);
                k.setJumlahDanaMasuk(jmlhDanaMsuk);
                k.setNama_anggota(atasNama);
                k.setPokokPinjaman(pokokpinjaman);
                k.setBunga(bunga);
                k.setCicilanKe(cicilanKe);
                k.setLamaPinjam(lamaPinjam);
                k.setAngsuran(angsuran);
                try {
                    PemasukanKontrol.getKoneksiPemasukan().tambahDataCicilan(k);
                    JOptionPane.showMessageDialog(this, "data berhasil disimpan");
                    kosong();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(this, "data gagal disimpan" + " \n error: " + ex.getMessage());
                }
            }
        }


    }//GEN-LAST:event_BtnSimpanActionPerformed

    private void BtnSimpan1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnSimpan1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_BtnSimpan1ActionPerformed

    private void bKeluarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bKeluarActionPerformed
        // TODO add your handling code here:
        this.dispose();
        FormUtama ut = new FormUtama();
        ut.getBtnPengeluaran().setEnabled(false);
        ut.setVisible(true);

    }//GEN-LAST:event_bKeluarActionPerformed

    private void ComboKdRekeningActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComboKdRekeningActionPerformed
        // set enable false n true tergantung kode rekening
        String x = (String) ComboKdRekening.getSelectedItem();
        //System.out.println(x+"-");
        if (x.equalsIgnoreCase("P1") || x.equalsIgnoreCase("P2") || x.equalsIgnoreCase("P3") || x.equalsIgnoreCase("P4")) {
            no_invoice();
            TFangsuran.setEnabled(false);
            TFBunga.setEnabled(false);
            tCicilanKe.setEnabled(false);
            tLamaPinjam.setEnabled(false);
            
            

        } else if (x.equalsIgnoreCase("P5")) {
            no_invoice();
            TFangsuran.setEnabled(true);
            TFBunga.setEnabled(true);
            tCicilanKe.setEnabled(true);
            TFJmlDnaMsk.setEnabled(false);
            tLamaPinjam.setEnabled(true);
            
        }

    }//GEN-LAST:event_ComboKdRekeningActionPerformed

    private void tInvoiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tInvoiceActionPerformed
    }//GEN-LAST:event_tInvoiceActionPerformed

    private void tIDAnggotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tIDAnggotaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tIDAnggotaActionPerformed

    private void tKeteranganActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tKeteranganActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tKeteranganActionPerformed

    private void tCicilanKeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tCicilanKeActionPerformed
        // TODO add your handling code here:
        this.getCicilan();
    }//GEN-LAST:event_tCicilanKeActionPerformed

    private void tIDAnggotaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tIDAnggotaKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == 10) {
            try {
                Pemasukan s = PemasukanKontrol.getKoneksiPemasukan().getNamaOtomatis(tIDAnggota.getText());
                if (s != null) {
                    tNamaAnggota.setText(s.getNama_anggota());
                } else {
                    JOptionPane.showMessageDialog(this, "Nama anggota tidak ditemukan!");
                }
            } catch (SQLException ex) {
                Logger.getLogger(FormPemasukan.class.getName()).log(Level.SEVERE, null, ex);
            }
        }


    }//GEN-LAST:event_tIDAnggotaKeyPressed

    private void ComboKdRekeningCaretPositionChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_ComboKdRekeningCaretPositionChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_ComboKdRekeningCaretPositionChanged

    private void TFangsuranKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TFangsuranKeyPressed
        // TODO add your handling code here:
       
    }//GEN-LAST:event_TFangsuranKeyPressed

    private void tLamaPinjamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tLamaPinjamActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tLamaPinjamActionPerformed

    private void tInvoiceKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tInvoiceKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_tInvoiceKeyPressed

    private void tLamaPinjamKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tLamaPinjamKeyPressed
        // setelah enter field ini maka nilai bunga akan keluar otomatis
//        if (evt.getKeyCode() == 10) {
//            float bunga;
//            float pokokPinjaman = Integer.parseInt(TFpokokPinjaman.getText());
//            bunga = (float) (pokokPinjaman * 0.3);
//            TFBunga.setText(String.valueOf(bunga));
//        }

        if (evt.getKeyCode() == 10) {
            int bunga;
            int pokokPinjaman = Integer.parseInt(TFangsuran.getText());
            int lamaPinjam = Integer.parseInt(tLamaPinjam.getText());
            bunga = pokokPinjaman * 2 / lamaPinjam;
            TFBunga.setText(String.valueOf(bunga));
            int totalDanaMasuk = bunga + pokokPinjaman;

            TFJmlDnaMsk.setText(String.valueOf(totalDanaMasuk));
            TFJmlDnaMsk.setEnabled(true);
        }
    }//GEN-LAST:event_tLamaPinjamKeyPressed

    private void bBatalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBatalActionPerformed
        // TODO add your handling code here
        kosong();
    }//GEN-LAST:event_bBatalActionPerformed

    private void TFJmlDnaMskKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TFJmlDnaMskKeyReleased
        // TODO add your handling code here:t
        cekAngka(TFJmlDnaMsk.getText());
//        TFJmlDnaMsk.setText("");
    }//GEN-LAST:event_TFJmlDnaMskKeyReleased

    private void TFangsuranKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TFangsuranKeyReleased
        // TODO add your handling code here:
        cekAngka(TFangsuran.getText());
//        TFpokokPinjaman.setText("");
    }//GEN-LAST:event_TFangsuranKeyReleased

    private void TFJmlDnaMskMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TFJmlDnaMskMousePressed
        // TODO add your handling code here:
//        TFJmlDnaMsk.setText("");
    }//GEN-LAST:event_TFJmlDnaMskMousePressed

    private void TFangsuranActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TFangsuranActionPerformed
        // TODO add your handling code here:
//        float pokokPinjaman = Integer.parseInt(TFpokokPinjaman.getText());
//        float bunga = (float) ((pokokPinjaman * 0.03)) / 12;
//        TFBunga.setText(String.valueOf(bunga));
////        float jumlah = bunga + (pokokPinjaman / 12);
//        float jumlah = bunga + (pokokPinjaman);
//
//        TFJmlDnaMsk.setText(String.valueOf(jumlah));
//        TFJmlDnaMsk.setEnabled(true);
         this.getangsuran();
    }//GEN-LAST:event_TFangsuranActionPerformed

    private void TFpokokPinjamanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TFpokokPinjamanActionPerformed
        // TODO add your handling code here:
       
             getPokokPinjaman();
        
       
        
    }//GEN-LAST:event_TFpokokPinjamanActionPerformed

    private void TFpokokPinjamanKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TFpokokPinjamanKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_TFpokokPinjamanKeyPressed

    private void TFpokokPinjamanKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TFpokokPinjamanKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_TFpokokPinjamanKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FormPemasukan().setVisible(true);


            }
        });




    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BtnSimpan;
    private javax.swing.JButton BtnSimpan1;
    private javax.swing.JComboBox ComboKdRekening;
    private javax.swing.JTextField TFBunga;
    private javax.swing.JTextField TFJmlDnaMsk;
    private javax.swing.JTextField TFangsuran;
    private javax.swing.JTextField TFpokokPinjaman;
    private javax.swing.JButton bBatal;
    private javax.swing.JButton bKeluar;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel labelAngsuran;
    private javax.swing.JLabel labelBunga;
    private javax.swing.JLabel labelBunga1;
    private javax.swing.JLabel labelBunga2;
    private javax.swing.JLabel labelBunga3;
    private javax.swing.JLabel labelBunga4;
    private javax.swing.JLabel labelJmlDnaMsk;
    private javax.swing.JLabel labelKdRekening;
    private javax.swing.JLabel labelPokokPinjaman;
    private javax.swing.JLabel labelSmberDna;
    private javax.swing.JLabel labelSmberDna1;
    private javax.swing.JLabel labelTgl;
    private javax.swing.JLabel labelTgl1;
    private javax.swing.JLabel pemasukkan;
    private javax.swing.JTextField tCicilanKe;
    private javax.swing.JTextField tIDAnggota;
    private javax.swing.JTextField tInvoice;
    private javax.swing.JTextField tKeterangan;
    private javax.swing.JTextField tLamaPinjam;
    private javax.swing.JTextField tNamaAnggota;
    private com.toedter.calendar.JDateChooser tTanggal;
    // End of variables declaration//GEN-END:variables

    public final String no_invoice() {
        try {
            String sql = "select max(No_invoice) from transaksi";
            Connection con = koneksi.getDBConnection();
            java.sql.Statement sta = con.createStatement();
            ResultSet rs = sta.executeQuery(sql);

            rs.next();
            String result = rs.getString(1);
            if (result != null) {
                int no = Integer.parseInt(result);
                no++;
                sql = "" + no;
                while (sql.length() <= 3) {
                    sql = "0" + sql;

                }
                tInvoice.setText(sql);
            } else {
                sql = "0001";
                tInvoice.setText(sql);
            }
            return sql;

        } catch (SQLException ex) {
            Logger.getLogger(Pengeluaran.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }

    }

//    public final String no_invoice1() {
//        try {
//            String sql = "select max(No_invoice) from pemasukan1";
//            Connection con = koneksi.getDBConnection();
//            java.sql.Statement sta = con.createStatement();
//            ResultSet rs = sta.executeQuery(sql);
//
//            rs.next();
//            String result = rs.getString(1);
//            if (result != null) {
//                int no = Integer.parseInt(result);
//                no++;
//                sql = "" + no;
//                while (sql.length() <= 3) {
//                    sql = "0" + sql;
//
//                }
//                tInvoice.setText(sql);
//            } else {
//                sql = "0001";
//                tInvoice.setText(sql);
//            }
//            return sql;
//
//        } catch (SQLException ex) {
//            Logger.getLogger(Pengeluaran.class.getName()).log(Level.SEVERE, null, ex);
//            return null;
//        }
//
//    }
    
    public void kosong() {
        tIDAnggota.setText("");
        tNamaAnggota.setText("");
        tKeterangan.setText("");
        TFJmlDnaMsk.setText("");
        TFangsuran.setText("");
        tLamaPinjam.setText("");
        tCicilanKe.setText("");
        TFBunga.setText("");
        TFpokokPinjaman.setText("");
        tIDAnggota.requestFocus();
    }

    private void cekAngka(String angka) {
        if (!angka.matches("[0-9]*")) {
            JOptionPane.showMessageDialog(rootPane, "Masukan harus angka");
        }
    }

    public String getCicilan() {
        try {
            String sql = "select MAX(cicilan_ke) from pemasukan1 where id_anggota ='" + tIDAnggota.getText() + "'";
            Connection conn = koneksi.getDBConnection();
            Statement stat = conn.createStatement();
            ResultSet rs = stat.executeQuery(sql);
            rs.next();
            String result = rs.getString(1);
            if (result != null) {
                int no = Integer.parseInt(result);
                no++;
                sql = "" + no;
                tCicilanKe.setText(sql);
            } else {
                sql = "1";
                tCicilanKe.setText(sql);
            }
            return sql;
        } catch (SQLException ex) {
            Logger.getLogger(FormPemasukan.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    
    public String getangsuran(){
        try {
            String sql = "select angsuran from pemasukan1 where id_anggota ='" + tIDAnggota.getText() + "'";
                Connection conn = koneksi.getDBConnection();
                Statement stat = conn.createStatement();
                ResultSet rs = stat.executeQuery(sql);
                rs.next();
                String result = rs.getString(1);
//                if (result != null) {
                    TFangsuran.setText(result);
//                } else {
//                    result = "null";
//                   TFpokokPinjaman.setText(result);
//                }
                return result;
        } catch (SQLException ex) {
            Logger.getLogger(FormPemasukan.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
        
    }
    
    public String getPokokPinjaman(){
             
        try {
          
            String sql = "select (pokok_pinjaman - angsuran) from pemasukan1"
                    + " where id_anggota = '" + tIDAnggota.getText() + "'"
                    + "and cicilan_ke = (select max(cicilan_ke) from pemasukan1 "
                    + "where id_anggota = '" + tIDAnggota.getText() + "')";
                Connection conn = koneksi.getDBConnection();
                Statement stat = conn.createStatement();
                ResultSet rs = stat.executeQuery(sql);
                rs.next();
                String result = rs.getString(1);
                int r = Integer.parseInt(result);
                if (r != 0) {
//                    double pokok = Double.parseDouble(result);
//                    double angsuran = Double.parseDouble(getangsuran());
//                    double sisa = pokok - angsuran;
                    TFpokokPinjaman.setText(result);
                } else {
//                    sql = "1";
//                    tCicilanKe.setText(sql);
                    JOptionPane.showMessageDialog(null, "Pinjaman anda sudah lunas");
                }
                return sql;
                
        } catch (SQLException ex) {
            Logger.getLogger(FormPemasukan.class.getName()).log(Level.SEVERE, null, ex);
        return null;
        }
        
    }
    
}
